package com.ymatou.iapi.trading.useranalysis.service;

import org.json.JSONObject;

import com.ymt.base.YmatouBaseCall;
import com.ymttest.utils.EnvSetup;

public class BatchBuyerFlagQueryCall extends YmatouBaseCall{
	
	private static String opurl = "api/buyerflag/BatchBuyerFlagQuery";

	public BatchBuyerFlagQueryCall() {
		super(EnvSetup.getSystemUrl("useranalysis_iapi"), opurl, "POST", "JSON");
	}

	@Override
	public void addDefHeader() {
		client.addHeader("Accept", "text/xml,text/javascript,text/html,application/json");
		client.addHeader("Content-Type", "application/json; charset=UTF-8");
	}
	
	/**
	 * 获取errorCode
	 * 
	 * @return
	 */
	public String getErrorCode() {
		
		String errorCode = null;
		
		try {
			errorCode = new JSONObject(getReturnData()).optString("errorCode");
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		return errorCode;
	}
	
	/**
	 * 获取success
	 * 
	 * @return
	 */
	public boolean getSuccess() {
		
		boolean success = false;
		
		try {
			success = new JSONObject(getReturnData()).optBoolean("success");
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		return success;
	}

	/**
	 * 获取errorMessage
	 * 
	 * @return
	 */
	public String getErrorMessage() {
		
		String errorMessage = null;
		
		try {
			errorMessage = new JSONObject(getReturnData()).optString("errorMessage");
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		return errorMessage;
	}

	/**
	 * 获取buyerId
	 * 
	 * @return
	 */
	public long getBuyerId() {
		
		long buyerId = 0;
		
		try {
			buyerId = new JSONObject(getReturnData()).optLong("buyerId");
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		return buyerId;
	}

	/**
	 * 获取flags
	 * 
	 * @return
	 */
	public JSONObject getFlags() {
		
		
		JSONObject flags = null;
		
		try {
			flags = new JSONObject(getReturnData()).optJSONObject("flags");
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		return flags;
	}
}
